home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / gamesmaster / demosrc / widescreen&sprite.s < prev    next >
Text File  |  1996-07-16  |  5KB  |  180 lines

  1. ;Horizontal Scroll 640
  2. ;---------------------
  3. ;This opens an extra wide screen of 256x640 pixels, and allows you to
  4. ;scroll left, right, up and down.  This is *totally* inadequate for
  5. ;games such as platformers and shoot'em-ups etc because the picture size
  6. ;takes  up  huge  amounts  of  memory.   However  for games like Skidmarks,
  7. ;Lemmings, Monkey Island, etc, such large screens can be a necessity.
  8.  
  9.     opt    o+
  10.  
  11.     INCLUDE    "exec/exec_lib.i"
  12.     INCLUDE    "games/games_lib.i"
  13.     INCLUDE    "games/games.i"
  14.     INCLUDE    "games/gamesbase.i"
  15.  
  16. CALL    MACRO
  17.     jsr    _LVO\1(a6)
  18.     ENDM
  19.  
  20. LOCAL    =    0
  21.  
  22.     SECTION    "ExtraLarge640",CODE
  23.  
  24. ;===========================================================================;
  25. ;                             INITIALISE DEMO
  26. ;===========================================================================;
  27.  
  28. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  29.     move.l    ($4).w,a6
  30.     lea    GMS_Name(pc),a1
  31.     moveq    #$00,d0
  32.     CALL    OpenLibrary
  33.     move.l    d0,GMS_Base
  34.     beq    Quit
  35.  
  36.     move.l    GMS_Base(pc),a6          ;Set task at the user-specified
  37.     CALL    SetUserPri               ;priority.
  38.  
  39.     lea    ScreenStruct(pc),a0
  40.     CALL    Add_Screen
  41.     tst.l    d0
  42.     bne    Error
  43.  
  44.     move.l    SS_MemPtr1(a0),a1        ;Destination = SS_MemPtr1.
  45.     lea    PackedPicFile(pc),a0     ;File Name.
  46.     CALL    QuickLoad
  47.     tst.l    d0
  48.     beq    Error
  49.  
  50.     lea    ScreenStruct(pc),a0      ;Unpack the data on top of itself.
  51.     move.l    SS_MemPtr1(a0),a1
  52.     move.l    a1,a0
  53.     moveq    #$00,d0
  54.     CALL    SmartUnpack
  55.  
  56.     lea    ScreenStruct(pc),a0
  57.     lea    SparkieStruct(pc),a1
  58.     CALL    Init_Sprite
  59.     CALL    Update_Sprite            ;First get him onto the screen.
  60.  
  61.     CALL    Show_Screen
  62.  
  63. ;===========================================================================;
  64. ;                                MAIN LOOP
  65. ;===========================================================================;
  66.  
  67. Loop:    addq.w    #1,d7                    ;Animation/Frame delay, so that
  68.     btst    #0,d7                    ; our anim does not run too fast!
  69.     beq.s    .mouse
  70.     cmp.w    #5,SPR_Frame(a1)         ;Do the animation for the sprite.
  71.     beq.s    .reset                   ;(simply by increasing the frame
  72.     addq.w    #1,SPR_Frame(a1)         ; number).
  73.     bra.s    .mouse
  74. .reset    clr.w    SPR_Frame(a1)
  75. .mouse    moveq    #JPORT1,d0               ;Read from port 1
  76.     CALL    Read_Mouse               ;Go get mouse position.
  77.     move.l    d0,SPR_XPos(a1)          ;Update the X/Y positions in one go.
  78.  
  79.     tst.w    Direction
  80.     beq.s    .Right
  81. .Left    cmp.w    #-16,SS_ScrollXCount(a0)
  82.     ble.s    .Right
  83.     move.w    #1,Direction
  84.     moveq    #-1,d0
  85.     bra.s    .scroll
  86. .Right    cmp.w    #320-16,SS_ScrollXCount(a0)
  87.     bge.s    .Left
  88.     clr.w    Direction
  89.     moveq    #1,d0
  90. .scroll    CALL    HWScroll_Horizontal      ;Reposition_Screen
  91.  
  92.     CALL    Wait_OSVBL
  93.     CALL    Update_Sprite            ;Put Sparkie on the screen.
  94.  
  95.     btst    #M_LMB,MouseButtons1+1(a6)
  96.     beq.s    Loop
  97.  
  98. ;===========================================================================;
  99. ;                              RETURN TO DOS
  100. ;===========================================================================;
  101.  
  102.     CALL    Delete_Screen            ;Give back screen memory etc.
  103. Error    move.l    GMS_Base(pc),a1
  104.     move.l    ($4).w,a6
  105.     CALL    CloseLibrary
  106. Quit    MOVEM.L    (SP)+,A0-A6/D1-D7
  107.     moveq    #$00,d0
  108.     rts
  109.  
  110. ;===========================================================================;
  111. ;                                  DATA
  112. ;===========================================================================;
  113.  
  114. Direction:
  115.     dc.w    0
  116.  
  117. GMS_Name:
  118.     dc.b    "games.library",0
  119.     even
  120. GMS_Base:
  121.     dc.l    0
  122.  
  123. AMT_PLANES =    4
  124.  
  125. SparkieStruct:
  126.     dc.w    0                        ;Number 0.
  127.     dc.l    Gfx_Sparkie              ;Ptr to graphic.
  128.     dc.w    100,100                  ;Beginning X/Y position
  129.     dc.w    0                        ;Current frame.
  130.     dc.w    16                       ;Width (16/32/64)
  131.     dc.w    21                       ;Height
  132.     dc.w    16                       ;Amt of colours.
  133.     dc.w    16                       ;Colour start in palette.
  134.     dc.w    4                        ;Amt of planes.
  135.     dc.w    SPR_AGA|LORES|XLONG      ;Attributes.
  136.     dc.l    0,0,0,0                  ;Private.
  137.  
  138. ScreenStruct:
  139.     dc.l    "GSV1"
  140.     dc.l    0,0,0                    ;Screen_Mem1/2/3
  141.     dc.l    0                        ;Screen link.
  142.     dc.l    ScreenPalette            ;Address of palette
  143.     dc.l    0                        ;Address of rasterlist.
  144.     dc.l    32                       ;Amt of colours in palette.
  145.     dc.w    256,320,320/8            ;Screen Height/Width/ByteWidth 
  146.     dc.w    256,640,640/8            ;Picture Height/Width/ByteWidth
  147.     dc.w    AMT_PLANES               ;Amt_Planes
  148.     dc.w    0,0                      ;Top Of Screen, X/Y
  149.     dc.w    16/8                     ;Scroll buffer in pixels/8.
  150.     dc.w    0                        ;X offset (for hor. scrolling).
  151.     dc.w    0                        ;Y offset (for ver. scrolling).
  152.     dc.l    NOBURST|HSCROLL          ;Special attributes.
  153.     dc.w    LORES                    ;Screen mode.
  154.     dc.b    INTERLEAVED              ;Screen type
  155.     dc.b    0                        ;Screen Is Being Displayed?
  156.     dc.l    0,0                      ;Reserved area.
  157.     even
  158.  
  159. ScreenPalette:
  160.     dc.w    $0000,$0400,$0501,$0501,$0601,$0701,$0701,$0801
  161.     dc.w    $0901,$0901,$0A02,$0432,$0CC0,$0F00,$0211,$0880
  162.     dc.w    $01C2,$0050,$0B0B,$0606,$0F20,$0910,$0BBB,$0FFF
  163.     dc.w    $00BF,$0068,$0568,$09BF,$0FF0,$0EE0,$0BA0,$0540
  164.  
  165. PackedPicFile:
  166.     IFNE    LOCAL
  167.     dc.b    "GAMESLIB:Demos/"
  168.     ENDC
  169.     dc.b    "data/Pic640x256.pak",0
  170.     even
  171.  
  172. ;===========================================================================;
  173.  
  174. ;===========================================================================;
  175.  
  176.     SECTION    "Graphics",DATA_C
  177.  
  178. Gfx_Sparkie:
  179.     INCBIN    "GAMESLIB:Store/Sparkie.raw"
  180.